# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.

# pyre-strict


from buck2.tests.e2e_util.api.buck import Buck
from buck2.tests.e2e_util.asserts import expect_failure
from buck2.tests.e2e_util.buck_workspace import buck_test


@buck_test()
async def test_not_bxl(buck: Buck) -> None:
    await expect_failure(
        buck.bxl(
            "//not_bxl.bxl:not_bxl",
        ),
        stderr_regex="Expected value of type `bxl` but got `function",
    )


@buck_test()
async def test_not_allowed_now(buck: Buck) -> None:
    await expect_failure(
        buck.build(":"),
        stderr_regex="This function can only be called from Bxl",
    )
